//
//  AXMyGzVC.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/17.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXMyGzVC.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "Header.h"
#import "AXMyGzTableViewCell.h"
#import "UIViewController+HBD.h"

@interface AXMyGzVC ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic ,strong) UITableView *tableView;
///** 假图片数据 */
//@property (nonatomic, strong) NSArray<NSString *> *titleNames;



@end

@implementation AXMyGzVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatView];
    [self setlayout];
    [self setupNavigationItems];
    
    
}




- (void)creatView {
    /** 表头创建 */
    self.tableView = [[UITableView alloc]init];
    self.tableView.tableFooterView = [UIView new];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[AXMyGzTableViewCell class] forCellReuseIdentifier:[AXMyGzTableViewCell reuseID]];
    [self.view addSubview:self.tableView];
    
}



- (void)setlayout {
    
    self.tableView.sd_layout
    .leftSpaceToView(self.view, 0)
    .topSpaceToView(self.view, NAVIGATION_HEIGHT)
    .widthIs(Wi)
    .heightIs(TableViewHeight);
    
    
}

- (void)setupNavigationItems {
    
    self.hbd_barTintColor = [UIColor whiteColor];
    self.hbd_barShadowHidden = YES;
    
    //返回按钮
    UIButton *kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [kfBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    kfBtn.frame = CGRectMake(0, 0, 30, 30);
    [kfBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:kfBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel.textColor = [UIColor colorWithHex:0x29b566];
    titleLabel.text = @"关注";
    self.navigationItem.titleView = titleLabel;
    
}

#pragma mark - Action

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}



#pragma mark - tableViewDelegate & tableViewDatasorce

//分区头
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    if (section == 0) {
        
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
        view .backgroundColor = [UIColor whiteColor];
        UILabel *titLable = [[UILabel alloc]init];
        titLable.font = FONT_FOURTEEN;
        titLable.text = @"你可能感兴趣的 ";
        titLable.textColor = COLOR_Gray;
        [view addSubview:titLable];
        titLable.sd_layout
        .leftSpaceToView(view, 10)
        .topSpaceToView(view, 0)
        .widthIs(150)
        .heightIs(30);
        
        UILabel *moreLablel = [[UILabel alloc]init];
        moreLablel.text = @"更多";
        moreLablel.font = FONT_FOURTEEN;
        moreLablel.textColor = COLOR_Gray;
        [view addSubview:moreLablel];
        
        moreLablel.sd_layout
        .rightSpaceToView(view, 10)
        .topSpaceToView(view, 0)
        .widthIs(50)
        .heightIs(30);
        
        
        return view;
    }
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
    view .backgroundColor = [UIColor whiteColor];
    UILabel *titLable = [[UILabel alloc]init];
    titLable.text = @"我的关注";
    titLable.font = FONT_FOURTEEN;
    titLable.textColor = COLOR_Gray;
    [view addSubview:titLable];
    titLable.sd_layout
    .leftSpaceToView(view, 10)
    .topSpaceToView(view, 0)
    .widthIs(150)
    .heightIs(30);
    

    return view;
}
/** 分区头的高 */
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    return 30;
}



//几个分区
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (section == 0) {
        
        return 3;
    }
   
    return 3;
}

/** cell的高度 */

/** cell 自适应第二步 */
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return 50;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    AXMyGzTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[AXMyGzTableViewCell reuseID] forIndexPath:indexPath];
//    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    
    
    return cell;
    
    
}



@end
